package com.ansion.user;


import com.ansion.user.api.UserSdkApi;

/***
 * 用户sdk对外暴露的类
 * 这里需要注意的是UserSdkFactory既有可能再UI调用，也有可能在子线程调用，所以需要使用double check形式去实例化UserSdkApi
 */
public class UserSdkFactory {
    private static volatile UserSdkApi sdkApi;

    public static UserSdkApi getSdk() {

        if (sdkApi == null) {
            synchronized (UserSdkApi.class) {
                if (sdkApi == null) {
                    try {
                        Class<?> aClass = Class.forName("com.ansion.commonchat.api.UserSdkImpl");
                        sdkApi = (UserSdkApi) aClass.newInstance();
                    } catch (Exception e) {
                        e.printStackTrace();
                    }
                }
            }

        }
        return sdkApi;
    }


}
